function [newgnd] = semi(data,gnd)
samp_num = size(data,1);
nnClass = length(unique(gnd))-1;  % The number of classes;
num_Class=[];
for i=1:nnClass
  num_Class=[num_Class length(find(gnd==i))]; %The number of samples of each class
end
runtimes = 1;
minU0 = 1e-12;
maxU0 = 1e5;  
W = data;
D = diag(sum(W));
for r=1:runtimes
    Y = zeros(samp_num, nnClass);
    cLab = zeros(samp_num, nnClass);
    FF = zeros(samp_num, nnClass);
    TestF = ones(samp_num, nnClass);
    U0 = zeros(samp_num, samp_num);
    Umin = minU0*ones(samp_num, samp_num);
    for  j=1:nnClass
        idx=find(gnd==j);
        sele = length(idx);
        cLab(idx, j) = 1;
        Y(idx(1:sele),j) = 1;
        TestF(idx(1:sele),:) = 0;      
        for s = 1:sele
            U0(idx(s),idx(s)) = maxU0;
        end
    end
    F = (D+U0-W+Umin)\U0*Y;
    [maxF, idF] = max(F,[],2);
    for j = 1:samp_num
        FF(j,idF(j)) = 1;
    end
    newgnd = zeros(samp_num,1);
    for i =1:nnClass
        a = find(FF(:,i)>0);
        newgnd(a) = i;
    end
end